package com.bestcem.xm.wallet.grpc.client.converter;

import com.bestcem.bp.xm.user.grpc.v1.services.Organization;
import com.bestcem.xm.user.util.business.mapstract.TransformStrategy;
import com.bestcem.xm.user.util.business.mapstract.TransformStrategyConstant;
import com.bestcem.xm.wallet.grpc.client.dto.OrganizationDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.NullValueCheckStrategy;

/**
 * 用户相关信息转换类
 *
 * @author qiongyu.cui <qiongyu.cui@idiaoyan.com>
 * @version v1.0
 * @date 2022/5/13 17:56
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface WalletUserGrpcConvert extends TransformStrategy {

    @Mappings({
            @Mapping(target = "orgId", source = "id"),
            @Mapping(target = "status", source = "statusValue"),
            @Mapping(target = "source", source = "sourceValue"),
            @Mapping(target = "formalExpireTime", source = "formalExpireTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE),
            @Mapping(target = "trialExpireTime", source = "trialExpireTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE),
            @Mapping(target = "packageExpireTime", source = "packageExpireTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE),
            @Mapping(target = "freeExpireTime", source = "freeExpireTime", qualifiedByName = TransformStrategyConstant.GRPC_TIMESTAMP_TO_DATE),
            @Mapping(target = "completeFlag", source = "complete", qualifiedByName = TransformStrategyConstant.BOOLEAN_TO_INTEGER),
            @Mapping(target = "footer", source = "footerValue"),
            @Mapping(target = "notifySalesFlag", source = "notifySales", qualifiedByName = TransformStrategyConstant.BOOLEAN_TO_INTEGER),
            @Mapping(target = "innerFlag", source = "inner", qualifiedByName = TransformStrategyConstant.BOOLEAN_TO_INTEGER),
            @Mapping(target = "corpWallet", source = "walletId"),
    })
    OrganizationDTO orgGrpc2Dto(Organization organization);
}
